<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
		
		<meta name="Description" content="" />
        <meta name="Keywords" content="" />
        
		<title>XSLT Templater - test</title>
		
		<link href="style.css" rel="stylesheet" type="text/css" />
		
		<script type="text/javascript" src="/jQuery-1.4.2.js"></script>
		<script type="text/javascript" src="/jquery.xslt.yui.js"></script>
		<script type="text/javascript">
		
			window.elements = 10;
		
			$(document).ready(function() {
			
				var xmlString = "<xml-message>"+
								"<message>It working with string representation of xml</message>"+
							"</xml-message>";
				var xslString = '<?xml version="1.0"?>'+
							'<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">'+
									'<xsl:template match="xml-message">'+
										'<p>Result: <xsl:value-of select="message/text()"/>!</p>'+
									'</xsl:template>'+
							'</xsl:stylesheet>';

				function step1() {			
					var time = new Date();
	
					var cache = {
						"xml":false,
						"xsl":false,
						"result":true
					}
					
					$('#test0').xslt(xmlString,xslString,function() {// Caching result
						$('#test1').xslt(xmlString,xslString,function(){// Using result
							var time2 = new Date();
						 	$("#time0").text("Calculating time:"+(time2-time));
						 	step2();
						},null,cache);
					},null, cache);
				}

				function step2(){
					var time = new Date();
	
					cache = {
						"xml":true,
						"xsl":false,
						"result":false
					}
	
					$('#test2').xslt(xmlString,xslString,function() { // Caching xml
						$('#test3').xslt(xmlString,xslString,function(){ // Using xml
							var time2 = new Date();
						 	$("#time1").text("Calculating time:"+(time2-time));
						 	step3();
						},null,cache);
					},null, cache);
				}

				function step3(){
					var time = new Date();
	
					cache = {
						"xml":false,
						"xsl":true,
						"result":false
					}
	
					$('#test4').xslt(xmlString,xslString,function() { // Caching xsl
						$('#test5').xslt(xmlString,xslString,function(){ // Using xsl
							var time2 = new Date();
						 	$("#time2").text("Calculating time:"+(time2-time));
						 	step4();
						},null,cache);
					},null, cache);
				}

				function step4(){
					var time = new Date();
	
					cache = {
						"xml":true,
						"xsl":true,
						"result":false
					}
	
					$('#test6').xslt(xmlString,xslString,function() { // Using xml(step2) and xsl(step3) 
						$('#test7').xslt(xmlString,xslString,function(){ // Using xml(step2) and xsl(step3)
							var time2 = new Date();
						 	$("#time3").text("Calculating time:"+(time2-time));
						 	step5();
						},null,cache);
					},null, cache);
				}

				function step5(){
					var time = new Date();
	
					cache = true
	
					$('#test8').xslt(xmlString,xslString,function() { // Using result(step1)
						$('#test9').xslt(xmlString,xslString,function(){ // Using result(step1)
							var time2 = new Date();
						 	$("#time4").text("Calculating time:"+(time2-time));
						},null,cache);
					},null, cache);
				}

				step1();
				
    			
			});
				
		</script>
		
	</head>

	<body>
	
		<img src="/XSLTTemplater.png" alt="XSLT Templater"/>
		
		<script type="text/javascript">
			for (var i=0;i<window.elements;i++) {
				document.write('<div id="test'+i+'" class="xsltConteiner"></div>');
			}
			for (var i=0,len=window.elements/2;i<len;i++) {
				document.write('<span id="time'+i+'" class="times"></span><br/>');
			}
		</script>
		
	</body>
</html>